import {
 	fileUpload,
 	ajax
} from '@/apis/comfunc'
import router from '@/pages/index/router'
import axios from 'axios'

export default{
	state:{
	},//state_end
	mutations:{
		
	},//muntations_end
	getters:{

	},//getters_end
	actions:{
		// 获取分组列表
	    fileUpload ({ commit },params) {
	      return new Promise((resolve, reject) => {
	      	var data = params;
	      	data.append('token',this.state.user.token)
	        fileUpload(data).then(res => {
	          const data = res.data;
	          resolve(data);
	        }).catch(err => {
	          reject(err)
	        })
	      })
	    },
	    ajax({ commit },{params}){
	    	const api = params.api;
	      	const type = params.type;
	      	const cityId = params.cityId||"";
	      	const token = this.state.user.token;
	      	var mctoken = ""; //获取牧场token
	      	if (router.currentRoute.query.token) {
	      		mctoken = router.currentRoute.query.token;
	      	}
	    	return new Promise((resolve, reject) => {
		      	ajax({token,api,type,mctoken,cityId}).then(res => {
		          const data = res.data;
		          resolve(data);
		        }).catch(err => {
		          reject(err)
		        })
		    })
	    }
	} // actions_end
}